#ifndef IDENT_H
#define IDENT_H
#include <string>
#include "lex.h"
//music 笑顔
using namespace std;

class ident
{
    string m_name;
    bool m_is_assigned;
    bool m_is_declared;
    value_t m_value;
    lex_type_t m_type;
public:

    bool operator == (const ident &t) {
        return (t.m_name == m_name);
    }

    ident(const string &name = "", lex_type_t type = LEX_NULL);
    string get_name() { //nomae wa m_name
        return m_name;//hora hora
    }
    void set_name(string &name) { //ima nomae wa
        m_name = name;
    }

    bool is_declared() {
        return m_is_declared;
    }

    void set_declared() {
        m_is_declared = true;
    }

    bool is_assigned() {
        return m_is_assigned;
    }

    void set_assigned() {
        m_is_assigned = true;
    }

    value_t get_value() {
        return m_value;
    }

    void set_value(value_t &val) {
        if (m_type == LEX_STRING) {
            *(m_value.val.s_value) = *(val.val.s_value);
        } else {
            m_value = val;
        }
    }

    lex_type_t get_type() {
        return m_type;
    }

    void set_type(lex_type_t t) {
        if (t == LEX_STRING && m_type != LEX_STRING) {
            m_value.val.s_value = new string();
        }
        m_value.type = t;
        m_type = t;
    }

    ~ident() {
        if (m_type == LEX_STRING) {
            //delete m_value.s_value;
        }
    }

};

#endif // IDENT_H
